#ifndef _ONEGAME_H_H_
#define _ONEGAME_H_H_

#include "global.h"
#include "RSCOMMU.h"
#include "RSBITMAP.h"
#include "RSDISK.h"

class ONEGAME
{
public:
	ONEGAME(UINT id);
	~ONEGAME();

	void StartGame(bool immeRun);
	void SetPriRead(bool priRead);
	void CreateTdiThread();
	UINT GetSpeed();
	bool CloseGame();

	UINT_PTR m_tdiSock;
	UINT m_id;

	RSCOMMU m_priCom,m_mainCom;
	RSBITMAP m_bitmap;

public:
	volatile bool m_priRead,m_immeRun,m_sparseFile;
	string m_idName;
	string m_bitmapName;
	LONGLONG m_diskSize;
	string m_runPath;
	BYTE m_status;

	
	CRITICAL_SECTION m_cs;

	
	RSDISK m_disk;

	HANDLE m_hPriorThread,m_hDownThread,m_hTdiThread;
	volatile bool m_downExit,m_priorExit,m_tdiExit;

	void CloseTdiSock();
	bool CheckGameUpdate();
	bool DownInitData();

	bool GetBasicInf();

	void CreatePriorThread();
	void ExitPriorThread();
	void CreateDownThread();
	void ExitDownThread();
	
	void ExitTdiThread();

	static DWORD WINAPI PriorThread(PVOID pvoid);
	static DWORD WINAPI DownThread(PVOID pvoid);
	static DWORD WINAPI TdiThread(PVOID pvoid);
};

#endif